{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 4b. Calculate solubility constants\n", "\n", "This allows you to calculate the solubility constants for all volatile-bearing melt species in the CHOSX system at a given *P*, *T*, and melt composition.\n", "\n", "It can be run for multiple sets of conditions defined in the input data frame or loaded from a csv file." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Python set-up\n", "You need to install VolFe once on your machine, if you haven't yet. Then we need to import a few Python packages (including VolFe). " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Install VolFe on your machine. Don't remove the # from this line!\n", "# pip install VolFe # Remove the first # in this line if you have not installed VolFe on your machine before.\n", "\n", "# import python packages\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import VolFe as vf" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Define the inputs\n", "\n", "This example is for a single set of conditions defined in a dataframe.\n", "\n", "This composition is from Brounce et al. (2014) with the updated Fe3+/FeT from Cottrell et al. (2021)." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# Define the melt composition, fO2 estimate, and T as a dictionary.\n", "my_analysis = {'Sample':'Sari15-04-33',\n", " 'T_C': 1200., # Temperature in 'C\n", " 'P_bar': 1000., # Pressure in bar\n", " 'SiO2': 47.89, # wt%\n", " 'TiO2': 0.75, # wt%\n", " 'Al2O3': 16.74, # wt%\n", " 'FeOT': 9.43, # wt%\n", " 'MnO': 0.18, # wt%\n", " 'MgO': 5.92, # wt%\n", " 'CaO': 11.58, # wt%\n", " 'Na2O': 2.14, # wt%\n", " 'K2O': 0.63, # wt%\n", " 'P2O5': 0.17, # wt%\n", " 'H2O': 4.17, # wt%\n", " 'CO2ppm': 1487., # ppm\n", " 'STppm': 1343.5, # ppm\n", " 'Xppm': 0., # ppm\n", " 'Fe3FeT': 0.177}\n", "\n", "# Turn the dictionary into a pandas dataframe, setting the index to 0.\n", "my_analysis = pd.DataFrame(my_analysis, index=[0])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We'll use the default options" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " option\n", "type \n", "COH_species yes_H2_CO_CH4_melt\n", "H2S_m True\n", "species X Ar\n", "Hspeciation none\n", "fO2 Kress91A\n", "... ...\n", "error 0.1\n", "print status False\n", "output csv True\n", "setup False\n", "high precision False\n", "\n", "[78 rows x 1 columns]\n" ] } ], "source": [ "# print default options in VolFe\n", "print(vf.default_models)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Run the calculation\n", "\n", "And this runs the calculation" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SamplePressure (bar)T ('C)SiO2TiO2Al2O3FeOTMnOMgOCaO...hydrogen optsulfide optsulfate opthydrogen sulfide optmethane optcarbon monoxide optspecies X solubility optCspeccomp optHspeccomp optDate
0Sari15-04-331000.01200.047.9486890.75091916.7605159.4415570.1802215.92725511.594191...Basalt_Hughes24ONeill21dilONeill22dilBasalt_Hughes24Basalt_Ardia13Basalt_Hughes24Ar_Basalt_HughesIPBasaltMORB_HughesIP2025-02-02 10:19:37.073547
\n", "

1 rows × 45 columns

\n", "
" ], "text/plain": [ "0 Sample Pressure (bar) T ('C) SiO2 TiO2 Al2O3 \\\n", "0 Sari15-04-33 1000.0 1200.0 47.948689 0.750919 16.760515 \n", "\n", "0 FeOT MnO MgO CaO ... hydrogen opt sulfide opt \\\n", "0 9.441557 0.180221 5.927255 11.594191 ... Basalt_Hughes24 ONeill21dil \n", "\n", "0 sulfate opt hydrogen sulfide opt methane opt carbon monoxide opt \\\n", "0 ONeill22dil Basalt_Hughes24 Basalt_Ardia13 Basalt_Hughes24 \n", "\n", "0 species X solubility opt Cspeccomp opt Hspeccomp opt \\\n", "0 Ar_Basalt_HughesIP Basalt MORB_HughesIP \n", "\n", "0 Date \n", "0 2025-02-02 10:19:37.073547 \n", "\n", "[1 rows x 45 columns]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "vf.calc_sol_consts(my_analysis)" ] } ], "metadata": { "kernelspec": { "display_name": "volfe-dev", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.0" } }, "nbformat": 4, "nbformat_minor": 2 }